package com.hdu.dwh.pojos.cube_pojos;

import java.util.Set;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class Cuboid {
    
    public Cuboid(String tag, Integer cubeId, Integer level, Set<Cuboid> nextLevelCuboids,
            Set<Cuboid> preLevelCuboids, Set<CuboidDimension> dimensions) {
        this.tag = tag;
        this.cubeId = cubeId;
        this.level = level;
        this.nextLevelCuboids = nextLevelCuboids;
        this.preLevelCuboids = preLevelCuboids;
        this.dimensions = dimensions;
        this.isStored = false;
    }

    /**
     * Cuboid构造函数，nextLevelCuboids和preLevelCuboids设为null
     * @param tag {@link Cuboid#tag}
     * @param cubeId {@link Cuboid#cubeId}
     * @param level {@link Cuboid#level}
     * @param dimensionSet {@link Cuboid#dimensions}
     */
    public Cuboid(String tag, Integer cubeId, Integer level, Set<CuboidDimension> dimensionSet) {
        this.tag = tag;
        this.cubeId = cubeId;
        this.level = level;
        this.dimensions = dimensionSet;
        this.nextLevelCuboids = null;
        this.preLevelCuboids = null;
        this.isStored = false;
    }

    @TableId(type = IdType.AUTO)
    private Integer id;
    
    private Long tableId;

    private String tag;

    @Schema(description = "该Cuboid是否已经保存到数据库中", hidden = true)
    private Boolean isStored;

    @NotNull
    private Integer cubeId;

    @NotNull
    private Integer level;

    @TableField(exist = false)
    private Set<Cuboid> nextLevelCuboids;

    @TableField(exist = false)
    private Set<Cuboid> preLevelCuboids;

    @TableField(exist = false)
    private Set<CuboidDimension> dimensions;

    @NotNull
    private String createdBy;


    @Override
    public int hashCode() {
        return java.util.Objects.hash(id, level); // 仅使用简单字段计算 hashCode
    }
    @Override
    public boolean equals(Object obj) {
        return super.equals(obj);
    }

    public Cuboid(String _tag, Integer _cubeId, Integer _level) {
        this.tag = _tag;
        this.cubeId = _cubeId;
        this.level = _level;
    }
}
